package com.mark.mall.web.platform.config;

import com.fasterxml.jackson.databind.SerializationFeature;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author admin
 */
@Configuration
public class MybatisPlusConfig {
    /**
     * SQL执行效率插件 3.2.0 移除
     *
     * @return
     */
//    @Bean
//    @Profile({"dev"}) // 指定环境为dev生效
//    public PerformanceInterceptor performanceInterceptor() {
//        PerformanceInterceptor interceptor = new PerformanceInterceptor();
//        // sql美化打印
//        interceptor.setFormat(true);
//        // 设置SQL超时时间
//        interceptor.setMaxTime(5000L);
//        return interceptor;
//    }


    /**
     * 全局序列化
     * @return
     */
    @Bean
    public Jackson2ObjectMapperBuilderCustomizer customizer(){
        return builder -> builder.featuresToEnable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
    }
}
